namespace SmartSoft.Lists
{
    using SmartSoft;
    using SmartSoft.Controls;
    using SmartSoft.Controls.ChildGridControls;
    using SmartSoft.ADP;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;
    using Stimulsoft.Base.Drawing;
    using Stimulsoft.Report;
    using Stimulsoft.Report.Components;


    public class FormDmTs0Editor : FormListEditor
    {
        private DataGridViewTextBoxColumn Column1;
        private DataGridViewTextBoxColumn Column2;
        private DataGridViewTextBoxColumn Column3;
        private NumericColumn Column4;
        private IContainer components;
        private GridControl grdDetail;
        private int ii_RowIndex = -1;
        private LabelControl lblDesc_EN;
        private LabelControl lblDien_Giai;
        private LabelControl lblMa_Nvon;
        private LabelControl lblMa_TGTS;
        private LabelControl lblNgay_Ps;
        private LabelControl lblSo_Ct_Ps;
        private LabelControl lblSo_Thang;
        private LabelControl lblTien0;
        private DataRow oDetailRow;
        private DmTsDataAccess oMethod = new DmTsDataAccess();
        private TextControl txtDesc_EN;
        private TextControl txtDien_Giai;
        private TextSearch txtMa_Nvon;
        private TextSearch txtMa_TGTS;
        public TextDate txtNgay_Ps;
        public TextControl txtSo_Ct_Ps;
        private TextNumeric txtSo_Thang;
        private TextControl txtTen_Nvon;
        private TextControl txtTen_TGTS;
        private Button CmdPrint;
        private TextNumeric txtTien0;

        public FormDmTs0Editor()
        {
            this.InitializeComponent();
            this.grdDetail.AutoGenerateColumns = false;
            //if (AppInstance.Bilingual != 1)
            //{
            //    this.lblDesc_EN.Visible = false;
            //    this.txtDesc_EN.Visible = false;
            //    this.txtDien_Giai.Width = (this.txtDesc_EN.Left + this.txtDesc_EN.Width) - this.txtDien_Giai.Left;
            //    this.txtDien_Giai.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            //}
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void grdDetail_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (((this.grdDetail.Rows.Count > 0) && (this.ii_RowIndex != e.RowIndex)) && ((this.grdDetail.CurrentRow != null) && (this.grdDetail.CurrentRow.DataBoundItem != null)))
            {
                this.ii_RowIndex = e.RowIndex;
                this.oDetailRow = ((DataRowView) this.grdDetail.CurrentRow.DataBoundItem).Row;
                this.OnShowObjects();
            }
        }

        private void InitializeComponent()
        {
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormDmTs0Editor));
            this.grdDetail = new SmartSoft.Controls.GridControl();
            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column4 = new SmartSoft.Controls.ChildGridControls.NumericColumn();
            this.txtNgay_Ps = new SmartSoft.Controls.TextDate();
            this.lblSo_Ct_Ps = new SmartSoft.Controls.LabelControl();
            this.lblNgay_Ps = new SmartSoft.Controls.LabelControl();
            this.txtSo_Ct_Ps = new SmartSoft.Controls.TextControl();
            this.txtDesc_EN = new SmartSoft.Controls.TextControl();
            this.txtDien_Giai = new SmartSoft.Controls.TextControl();
            this.txtTen_Nvon = new SmartSoft.Controls.TextControl();
            this.lblDesc_EN = new SmartSoft.Controls.LabelControl();
            this.txtMa_Nvon = new SmartSoft.Controls.TextSearch();
            this.lblDien_Giai = new SmartSoft.Controls.LabelControl();
            this.lblMa_Nvon = new SmartSoft.Controls.LabelControl();
            this.txtTen_TGTS = new SmartSoft.Controls.TextControl();
            this.txtMa_TGTS = new SmartSoft.Controls.TextSearch();
            this.lblMa_TGTS = new SmartSoft.Controls.LabelControl();
            this.txtTien0 = new SmartSoft.Controls.TextNumeric();
            this.lblTien0 = new SmartSoft.Controls.LabelControl();
            this.lblSo_Thang = new SmartSoft.Controls.LabelControl();
            this.txtSo_Thang = new SmartSoft.Controls.TextNumeric();
            this.CmdPrint = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.grdDetail)).BeginInit();
            this.SuspendLayout();
            // 
            // lblPhan_Loai
            // 
            this.lblPhan_Loai.Location = new System.Drawing.Point(12, 344);
            // 
            // txtMa_Loai1
            // 
            this.txtMa_Loai1.Location = new System.Drawing.Point(123, 341);
            this.txtMa_Loai1.TabIndex = 9;
            // 
            // txtMa_Loai2
            // 
            this.txtMa_Loai2.Location = new System.Drawing.Point(251, 341);
            this.txtMa_Loai2.TabIndex = 10;
            // 
            // txtMa_Loai3
            // 
            this.txtMa_Loai3.Location = new System.Drawing.Point(379, 341);
            this.txtMa_Loai3.TabIndex = 11;
            // 
            // grdDetail
            // 
            this.grdDetail.AllowUserToAddRows = false;
            this.grdDetail.AllowUserToDeleteRows = false;
            this.grdDetail.AllowUserToResizeRows = false;
            this.grdDetail.CheckAutoSize = true;
            this.grdDetail.CheckColor = false;
            this.grdDetail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column1,
            this.Column2,
            this.Column3,
            this.Column4});
            this.grdDetail.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdDetail.Location = new System.Drawing.Point(0, 138);
            this.grdDetail.Name = "grdDetail";
            this.grdDetail.ReadOnly = true;
            this.grdDetail.Size = new System.Drawing.Size(576, 214);
            this.grdDetail.TabIndex = 10;
            this.grdDetail.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.grdDetail_CellEnter);
            // 
            // Column1
            // 
            this.Column1.DataPropertyName = "Ngay_Ps";
            this.Column1.HeaderText = "Ngày";
            this.Column1.Name = "Column1";
            this.Column1.ReadOnly = true;
            this.Column1.Width = 62;
            // 
            // Column2
            // 
            this.Column2.DataPropertyName = "So_Ct_Ps";
            this.Column2.HeaderText = "Số";
            this.Column2.Name = "Column2";
            this.Column2.ReadOnly = true;
            this.Column2.Width = 70;
            // 
            // Column3
            // 
            this.Column3.DataPropertyName = "Dien_Giai";
            this.Column3.HeaderText = "Diễn giải";
            this.Column3.Name = "Column3";
            this.Column3.ReadOnly = true;
            this.Column3.Width = 301;
            // 
            // Column4
            // 
            this.Column4.DataPropertyName = "Tien0";
            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column4.DefaultCellStyle = dataGridViewCellStyle1;
            this.Column4.HeaderText = "Số tiền";
            this.Column4.Name = "Column4";
            this.Column4.ReadOnly = true;
            this.Column4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column4.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.LocalAmount;
            // 
            // txtNgay_Ps
            // 
            this.txtNgay_Ps.DateTimeFormat = SmartSoft.Controls.TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ps.Enabled = false;
            this.txtNgay_Ps.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNgay_Ps.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
            this.txtNgay_Ps.Location = new System.Drawing.Point(97, 28);
            this.txtNgay_Ps.Mask = "00/00/0000";
            this.txtNgay_Ps.Name = "txtNgay_Ps";
            this.txtNgay_Ps.OldValue = null;
            this.txtNgay_Ps.Size = new System.Drawing.Size(100, 20);
            this.txtNgay_Ps.TabIndex = 0;
            this.txtNgay_Ps.Value = ((object)(resources.GetObject("txtNgay_Ps.Value")));
            // 
            // lblSo_Ct_Ps
            // 
            this.lblSo_Ct_Ps.AutoSize = true;
            this.lblSo_Ct_Ps.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblSo_Ct_Ps.Location = new System.Drawing.Point(248, 31);
            this.lblSo_Ct_Ps.Name = "lblSo_Ct_Ps";
            this.lblSo_Ct_Ps.Size = new System.Drawing.Size(67, 14);
            this.lblSo_Ct_Ps.TabIndex = 41;
            this.lblSo_Ct_Ps.Text = "Số chứng từ";
            // 
            // lblNgay_Ps
            // 
            this.lblNgay_Ps.AutoSize = true;
            this.lblNgay_Ps.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNgay_Ps.Location = new System.Drawing.Point(13, 31);
            this.lblNgay_Ps.Name = "lblNgay_Ps";
            this.lblNgay_Ps.Size = new System.Drawing.Size(79, 14);
            this.lblNgay_Ps.TabIndex = 42;
            this.lblNgay_Ps.Text = "Ngày phát sinh";
            // 
            // txtSo_Ct_Ps
            // 
            this.txtSo_Ct_Ps.CheckTextSearched = false;
            this.txtSo_Ct_Ps.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtSo_Ct_Ps.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtSo_Ct_Ps.Location = new System.Drawing.Point(321, 28);
            this.txtSo_Ct_Ps.Name = "txtSo_Ct_Ps";
            this.txtSo_Ct_Ps.OldValue = null;
            this.txtSo_Ct_Ps.ReadOnly = true;
            this.txtSo_Ct_Ps.Size = new System.Drawing.Size(90, 20);
            this.txtSo_Ct_Ps.TabIndex = 1;
            this.txtSo_Ct_Ps.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtSo_Ct_Ps.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtSo_Ct_Ps.Value = ((object)(resources.GetObject("txtSo_Ct_Ps.Value")));
            // 
            // txtDesc_EN
            // 
            this.txtDesc_EN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtDesc_EN.CheckTextSearched = false;
            this.txtDesc_EN.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtDesc_EN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDesc_EN.Location = new System.Drawing.Point(97, 112);
            this.txtDesc_EN.Name = "txtDesc_EN";
            this.txtDesc_EN.OldValue = null;
            this.txtDesc_EN.ReadOnly = true;
            this.txtDesc_EN.Size = new System.Drawing.Size(165, 20);
            this.txtDesc_EN.TabIndex = 8;
            this.txtDesc_EN.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtDesc_EN.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDesc_EN.Value = ((object)(resources.GetObject("txtDesc_EN.Value")));
            // 
            // txtDien_Giai
            // 
            this.txtDien_Giai.CheckTextSearched = false;
            this.txtDien_Giai.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtDien_Giai.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDien_Giai.Location = new System.Drawing.Point(321, 112);
            this.txtDien_Giai.Name = "txtDien_Giai";
            this.txtDien_Giai.OldValue = null;
            this.txtDien_Giai.ReadOnly = true;
            this.txtDien_Giai.Size = new System.Drawing.Size(187, 20);
            this.txtDien_Giai.TabIndex = 9;
            this.txtDien_Giai.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtDien_Giai.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDien_Giai.Value = ((object)(resources.GetObject("txtDien_Giai.Value")));
            // 
            // txtTen_Nvon
            // 
            this.txtTen_Nvon.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Nvon.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Nvon.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Nvon.CheckTextSearched = false;
            this.txtTen_Nvon.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nvon.Enabled = false;
            this.txtTen_Nvon.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Nvon.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nvon.Location = new System.Drawing.Point(203, 73);
            this.txtTen_Nvon.Name = "txtTen_Nvon";
            this.txtTen_Nvon.OldValue = null;
            this.txtTen_Nvon.Size = new System.Drawing.Size(361, 13);
            this.txtTen_Nvon.TabIndex = 5;
            this.txtTen_Nvon.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_Nvon.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Nvon.Value = ((object)(resources.GetObject("txtTen_Nvon.Value")));
            // 
            // lblDesc_EN
            // 
            this.lblDesc_EN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblDesc_EN.AutoSize = true;
            this.lblDesc_EN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDesc_EN.Location = new System.Drawing.Point(13, 115);
            this.lblDesc_EN.Name = "lblDesc_EN";
            this.lblDesc_EN.Size = new System.Drawing.Size(47, 14);
            this.lblDesc_EN.TabIndex = 105;
            this.lblDesc_EN.Text = "Bộ phận";
            // 
            // txtMa_Nvon
            // 
            this.txtMa_Nvon.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Nvon.CheckTextSearched = false;
            this.txtMa_Nvon.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Nvon.FieldDisplay = "Ten_Nvon";
            this.txtMa_Nvon.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Nvon.Location = new System.Drawing.Point(97, 70);
            this.txtMa_Nvon.MaxLength = 32;
            this.txtMa_Nvon.Name = "txtMa_Nvon";
            this.txtMa_Nvon.OldValue = null;
            this.txtMa_Nvon.ReadOnly = true;
            this.txtMa_Nvon.Size = new System.Drawing.Size(100, 20);
            this.txtMa_Nvon.TabIndex = 4;
            this.txtMa_Nvon.TableName = "DMNVON";
            this.txtMa_Nvon.TextDisplay = this.txtTen_Nvon;
            this.txtMa_Nvon.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Nvon.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Nvon.Value = ((object)(resources.GetObject("txtMa_Nvon.Value")));
            // 
            // lblDien_Giai
            // 
            this.lblDien_Giai.AutoSize = true;
            this.lblDien_Giai.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDien_Giai.Location = new System.Drawing.Point(268, 115);
            this.lblDien_Giai.Name = "lblDien_Giai";
            this.lblDien_Giai.Size = new System.Drawing.Size(47, 14);
            this.lblDien_Giai.TabIndex = 106;
            this.lblDien_Giai.Text = "Diễn giải";
            // 
            // lblMa_Nvon
            // 
            this.lblMa_Nvon.AutoSize = true;
            this.lblMa_Nvon.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Nvon.Location = new System.Drawing.Point(12, 73);
            this.lblMa_Nvon.Name = "lblMa_Nvon";
            this.lblMa_Nvon.Size = new System.Drawing.Size(59, 14);
            this.lblMa_Nvon.TabIndex = 104;
            this.lblMa_Nvon.Text = "Nguồn vốn";
            // 
            // txtTen_TGTS
            // 
            this.txtTen_TGTS.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_TGTS.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_TGTS.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_TGTS.CheckTextSearched = false;
            this.txtTen_TGTS.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_TGTS.Enabled = false;
            this.txtTen_TGTS.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_TGTS.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_TGTS.Location = new System.Drawing.Point(203, 52);
            this.txtTen_TGTS.Name = "txtTen_TGTS";
            this.txtTen_TGTS.OldValue = null;
            this.txtTen_TGTS.Size = new System.Drawing.Size(361, 13);
            this.txtTen_TGTS.TabIndex = 3;
            this.txtTen_TGTS.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_TGTS.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_TGTS.Value = ((object)(resources.GetObject("txtTen_TGTS.Value")));
            // 
            // txtMa_TGTS
            // 
            this.txtMa_TGTS.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_TGTS.CheckTextSearched = false;
            this.txtMa_TGTS.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_TGTS.FieldDisplay = "Ten_TGTS";
            this.txtMa_TGTS.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_TGTS.Location = new System.Drawing.Point(97, 49);
            this.txtMa_TGTS.MaxLength = 32;
            this.txtMa_TGTS.Name = "txtMa_TGTS";
            this.txtMa_TGTS.OldValue = null;
            this.txtMa_TGTS.ReadOnly = true;
            this.txtMa_TGTS.Size = new System.Drawing.Size(100, 20);
            this.txtMa_TGTS.TabIndex = 2;
            this.txtMa_TGTS.TableName = "DMTGTS";
            this.txtMa_TGTS.TextDisplay = this.txtTen_TGTS;
            this.txtMa_TGTS.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_TGTS.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_TGTS.Value = ((object)(resources.GetObject("txtMa_TGTS.Value")));
            // 
            // lblMa_TGTS
            // 
            this.lblMa_TGTS.AutoSize = true;
            this.lblMa_TGTS.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_TGTS.Location = new System.Drawing.Point(13, 52);
            this.lblMa_TGTS.Name = "lblMa_TGTS";
            this.lblMa_TGTS.Size = new System.Drawing.Size(34, 14);
            this.lblMa_TGTS.TabIndex = 102;
            this.lblMa_TGTS.Text = "Lý do";
            // 
            // txtTien0
            // 
            this.txtTien0.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTien0.Location = new System.Drawing.Point(97, 91);
            this.txtTien0.Name = "txtTien0";
            this.txtTien0.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtTien0.OldValue = null;
            this.txtTien0.ReadOnly = true;
            this.txtTien0.Size = new System.Drawing.Size(100, 20);
            this.txtTien0.TabIndex = 6;
            this.txtTien0.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtTien0.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.txtTien0.Value = ((object)(resources.GetObject("txtTien0.Value")));
            // 
            // lblTien0
            // 
            this.lblTien0.AutoSize = true;
            this.lblTien0.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTien0.Location = new System.Drawing.Point(12, 94);
            this.lblTien0.Name = "lblTien0";
            this.lblTien0.Size = new System.Drawing.Size(40, 14);
            this.lblTien0.TabIndex = 106;
            this.lblTien0.Text = "Số tiền";
            // 
            // lblSo_Thang
            // 
            this.lblSo_Thang.AutoSize = true;
            this.lblSo_Thang.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblSo_Thang.Location = new System.Drawing.Point(218, 95);
            this.lblSo_Thang.Name = "lblSo_Thang";
            this.lblSo_Thang.Size = new System.Drawing.Size(97, 14);
            this.lblSo_Thang.TabIndex = 106;
            this.lblSo_Thang.Text = "Số tháng khấu hao";
            // 
            // txtSo_Thang
            // 
            this.txtSo_Thang.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtSo_Thang.Location = new System.Drawing.Point(321, 91);
            this.txtSo_Thang.Name = "txtSo_Thang";
            this.txtSo_Thang.NumericScaleOnFocus = 0;
            this.txtSo_Thang.NumericScaleOnLostFocus = 0;
            this.txtSo_Thang.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtSo_Thang.OldValue = null;
            this.txtSo_Thang.ReadOnly = true;
            this.txtSo_Thang.Size = new System.Drawing.Size(90, 20);
            this.txtSo_Thang.TabIndex = 7;
            this.txtSo_Thang.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtSo_Thang.UserTextNumericFormat = SmartSoft.AppInstance.TextNumericFormat.None;
            this.txtSo_Thang.Value = ((object)(resources.GetObject("txtSo_Thang.Value")));
            // 
            // CmdPrint
            // 
            this.CmdPrint.Location = new System.Drawing.Point(410, 0);
            this.CmdPrint.Name = "CmdPrint";
            this.CmdPrint.Size = new System.Drawing.Size(166, 24);
            this.CmdPrint.TabIndex = 11;
            this.CmdPrint.Text = "In biên bản sửa chữa lớn";
            this.CmdPrint.UseVisualStyleBackColor = true;
            this.CmdPrint.Click += new System.EventHandler(this.CmdPrint_Click);
            // 
            // FormDmTs0Editor
            // 
            this.AddTitleText = "Sửa chữa tài sản, công cụ";
            this.ClientSize = new System.Drawing.Size(576, 375);
            this.Controls.Add(this.txtSo_Thang);
            this.Controls.Add(this.txtTien0);
            this.Controls.Add(this.txtTen_Nvon);
            this.Controls.Add(this.lblSo_Thang);
            this.Controls.Add(this.txtDien_Giai);
            this.Controls.Add(this.txtMa_Nvon);
            this.Controls.Add(this.CmdPrint);
            this.Controls.Add(this.lblTien0);
            this.Controls.Add(this.txtDesc_EN);
            this.Controls.Add(this.lblMa_Nvon);
            this.Controls.Add(this.txtTen_TGTS);
            this.Controls.Add(this.txtMa_TGTS);
            this.Controls.Add(this.lblMa_TGTS);
            this.Controls.Add(this.txtNgay_Ps);
            this.Controls.Add(this.lblSo_Ct_Ps);
            this.Controls.Add(this.lblNgay_Ps);
            this.Controls.Add(this.lblDesc_EN);
            this.Controls.Add(this.txtSo_Ct_Ps);
            this.Controls.Add(this.grdDetail);
            this.Controls.Add(this.lblDien_Giai);
            this.EditTitleText = "Sửa chữa tài sản, công cụ";
            this.Name = "FormDmTs0Editor";
            this.ShowDeleteButton = true;
            this.ShowEditButton = true;
            this.ShowFreeFields = false;
            this.Text = "Sửa chữa tài sản";
            this.Controls.SetChildIndex(this.lblDien_Giai, 0);
            this.Controls.SetChildIndex(this.grdDetail, 0);
            this.Controls.SetChildIndex(this.txtSo_Ct_Ps, 0);
            this.Controls.SetChildIndex(this.lblDesc_EN, 0);
            this.Controls.SetChildIndex(this.lblNgay_Ps, 0);
            this.Controls.SetChildIndex(this.lblSo_Ct_Ps, 0);
            this.Controls.SetChildIndex(this.txtNgay_Ps, 0);
            this.Controls.SetChildIndex(this.lblMa_TGTS, 0);
            this.Controls.SetChildIndex(this.txtMa_TGTS, 0);
            this.Controls.SetChildIndex(this.txtTen_TGTS, 0);
            this.Controls.SetChildIndex(this.lblMa_Nvon, 0);
            this.Controls.SetChildIndex(this.txtDesc_EN, 0);
            this.Controls.SetChildIndex(this.lblTien0, 0);
            this.Controls.SetChildIndex(this.CmdPrint, 0);
            this.Controls.SetChildIndex(this.txtMa_Nvon, 0);
            this.Controls.SetChildIndex(this.txtDien_Giai, 0);
            this.Controls.SetChildIndex(this.lblSo_Thang, 0);
            this.Controls.SetChildIndex(this.txtTen_Nvon, 0);
            this.Controls.SetChildIndex(this.txtTien0, 0);
            this.Controls.SetChildIndex(this.txtSo_Thang, 0);
            this.Controls.SetChildIndex(this.lblPhan_Loai, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai1, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai2, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai3, 0);
            ((System.ComponentModel.ISupportInitialize)(this.grdDetail)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        protected override void OnAdd()
        {
            base.OnAdd();
            this.oDetailRow = base.LocalTable.NewRow();
            this.oDetailRow["Stt0"] = SSDataAccess.Cong_So_Tt(AppInstance.Subsidiary);
            this.oDetailRow["Ngay_Ps"] = DateTime.Today;
            this.txtNgay_Ps.Value = DateTime.Today;
            this.txtNgay_Ps.Focus();
        }

        protected override void OnCancel()
        {
            if (((this.grdDetail.Rows.Count > 0) && (this.grdDetail.CurrentRow != null)) && (this.grdDetail.CurrentRow.DataBoundItem != null))
            {
                this.ii_RowIndex = this.grdDetail.CurrentCell.RowIndex;
                this.oDetailRow = ((DataRowView) this.grdDetail.CurrentRow.DataBoundItem).Row;
                this.OnShowObjects();
            }
            base.OnCancel();
        }

        protected override void OnDelete()
        {
            if ((((this.oDetailRow != null) && (this.oDetailRow.RowState != DataRowState.Deleted)) && (this.oDetailRow.RowState != DataRowState.Detached)) && (MessageBox.Show(AppInstance.DeleMessage, AppInstance.SoftwareName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
            {
                this.ii_RowIndex = -1;
                this.oMethod.DeleteDetailRow0(base.LocalCurrentRow["Stt"], this.oDetailRow["Stt0"]);
                base.LocalTable.Rows.Remove(this.oDetailRow);
                if (((this.grdDetail.Rows.Count > 0) && (this.grdDetail.CurrentRow != null)) && (this.grdDetail.CurrentRow.DataBoundItem != null))
                {
                    this.ii_RowIndex = this.grdDetail.CurrentCell.RowIndex;
                    this.oDetailRow = ((DataRowView) this.grdDetail.CurrentRow.DataBoundItem).Row;
                    this.OnShowObjects();
                }
                else
                {
                    this.oDetailRow = null;
                }
            }
        }

        protected override void OnEdit()
        {
            base.OnEdit();
            this.txtNgay_Ps.Focus();
        }

        protected override void OnReset()
        {
            base.LocalTable = this.oMethod.GetDetailTable0(base.LocalCurrentRow["Stt"]);
            this.grdDetail.DataSource = new BindingSource(base.LocalTable, base.LocalTable.TableName);
            base.OnReset();
        }

        protected override void OnResetStatus(bool pb_Status)
        {
            this.txtNgay_Ps.Enabled = !pb_Status;
            this.txtSo_Ct_Ps.ReadOnly = pb_Status;
            this.txtMa_TGTS.ReadOnly = pb_Status;
            this.txtMa_Nvon.ReadOnly = pb_Status;
            this.txtTien0.ReadOnly = pb_Status;
            this.txtSo_Thang.ReadOnly = pb_Status;
            this.txtDien_Giai.ReadOnly = pb_Status;
            this.txtDesc_EN.ReadOnly = pb_Status;
            this.grdDetail.Enabled = pb_Status;
            base.OnResetStatus(pb_Status);
        }

        public override bool OnSave()
        {
            if (((this.oDetailRow == null) || (this.oDetailRow.RowState == DataRowState.Deleted)) || ((this.oDetailRow.RowState == DataRowState.Detached) && !base.NewChecked))
            {
                return true;
            }
            if (this.txtNgay_Ps.Value.Equals(DBNull.Value) && this.txtNgay_Ps.Value.Equals(SDBNull.Value))
            {
                MessageBox.Show("Chưa nhập ngày sửa tài sản!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (((DateTime) this.txtNgay_Ps.Value) < AppInstance.OpeningDateOfSubEnterprice)
            {
                MessageBox.Show("Ngày phải bắt đầu từ " + AppInstance.OpeningDateOfSubEnterprice.ToShortDateString() + "!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (this.txtMa_TGTS.Value.Equals(DBNull.Value) && this.txtMa_TGTS.Value.Equals(SDBNull.Value))
            {
                MessageBox.Show("Chưa nhập lý do sửa chữa tài sản!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (this.txtMa_Nvon.Value.Equals(DBNull.Value) && this.txtMa_Nvon.Value.Equals(SDBNull.Value))
            {
                MessageBox.Show("Chưa nhập mã nguồn vốn!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (this.txtTien0.NumericValue == 0M)
            {
                MessageBox.Show("Chưa nhập giá trị sửa chữa tài sản!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (this.txtSo_Thang.NumericValue == 0M)
            {
                MessageBox.Show("Chưa nhập số tháng khấu hao!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (string.IsNullOrEmpty(this.oDetailRow["Stt0"].ToString()))
            {
                this.oDetailRow["Stt0"] = SSDataAccess.Cong_So_Tt(AppInstance.Subsidiary);
            }
            if (this.oDetailRow != null)
            {
                this.oDetailRow["Ngay_Ps"] = this.txtNgay_Ps.Value;
                this.oDetailRow["So_Ct_Ps"] = this.txtSo_Ct_Ps.Value;
                this.oDetailRow["Ma_TGTS"] = this.txtMa_TGTS.Value;
                this.oDetailRow["Ten_TGTS"] = this.txtTen_TGTS.Value;
                this.oDetailRow["Ma_Nvon"] = this.txtMa_Nvon.Value;
                this.oDetailRow["Ten_Nvon"] = this.txtTen_Nvon.Value;
                this.oDetailRow["Tien0"] = this.txtTien0.Value;
                this.oDetailRow["So_Thang"] = this.txtSo_Thang.Value;
                this.oDetailRow["Dien_Giai"] = this.txtDien_Giai.Value;
                this.oDetailRow["Desc_EN"] = this.txtDesc_EN.Value;
            }
            if (base.NewChecked && (this.oDetailRow.RowState != DataRowState.Added))
            {
                base.LocalTable.Rows.Add(this.oDetailRow);
                BindingSource dataSource = this.grdDetail.DataSource as BindingSource;
                dataSource.Position = dataSource.Find("Stt0", this.oDetailRow["Stt0"]);
            }
            this.oMethod.SaveDetailRow0(base.LocalCurrentRow["Stt"], this.oDetailRow);
            return base.OnSave();
        }

        private void OnShowObjects()
        {
            this.txtNgay_Ps.Value = this.oDetailRow["Ngay_Ps"];
            this.txtSo_Ct_Ps.Value = this.oDetailRow["So_Ct_Ps"];
            this.txtMa_TGTS.Value = this.oDetailRow["Ma_TGTS"];
            this.txtTen_TGTS.Value = this.oDetailRow["Ten_TGTS"];
            this.txtMa_Nvon.Value = this.oDetailRow["Ma_Nvon"];
            this.txtTen_Nvon.Value = this.oDetailRow["Ten_Nvon"];
            this.txtTien0.Value = this.oDetailRow["Tien0"];
            this.txtSo_Thang.Value = this.oDetailRow["So_Thang"];
            this.txtDien_Giai.Value = this.oDetailRow["Dien_Giai"];
            this.txtDesc_EN.Value = this.oDetailRow["Desc_EN"];
        }

        private void CmdPrint_Click(object sender, EventArgs e)
        {
            StiReport report = new StiReport();
            DataTable datatable1 = this.oMethod.GetMasterDataRow(base.LocalCurrentRow["Stt"]).Table.Copy();
            report.RegData("DmTs", datatable1);
            report.RegData("BS04TS", oDetailRow.Table.Copy());
            report.Load(Application.StartupPath + "\\ReportFiles\\BS04TS.mrt");
            report.Show();
        }
    }
}

